package com.liyong.pullorder.channels.autoconfigure;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.HashMap;
import java.util.Map;

@Data
@ConfigurationProperties(prefix = "channels-pull-sdk")
public class ChannelsPullProperties {
    private boolean enabled = true;
    private HttpClient httpClient = new HttpClient();
    private Retry retry = new Retry();
    private Map<String, Platform> platforms = new HashMap<>();

    @Data
    public static class HttpClient {
        private int maxTotal = 200;
        private int maxPerRoute = 50;
        private int connectTimeout = 5000;
        private int socketTimeout = 30000;
        private int connectionRequestTimeout = 2000;
    }

    @Data
    public static class Retry {
        private int maxAttempts = 3;
        private long backoff = 1000L;
        private double multiplier = 2.0;
    }

    @Data
    public static class Platform {
        private String baseUrl;
        private Auth auth = new Auth();
        private Parser parser = new Parser();
        private Map<String, String> headers = new HashMap<>();
    }

    @Data
    public static class Auth {
        private String type; // OAUTH2, API_KEY
        private Map<String, String> config = new HashMap<>();
    }

    @Data
    public static class Parser {
        private String format = "JSON"; // JSON, XML
        private Map<String, String> fieldMapping = new HashMap<>();
    }
}